<script>
import {
  defineComponent,
  reactive,
  toRefs
} from 'vue'

export default defineComponent({
  name: 'InfoButton',
  props: {
    title: {
      type: String,
      default: '按钮'
    },
    width: {
      type: Number,
      default: 80
    },
    disabled: {
      type: Boolean,
      default: false
    }
  },
  setup(props, { emit }) {
    const state = reactive({})

    const handleButtonClick = (e) => {
      if(!props.disabled) {
        emit('click', e)
      }
    }

    return {
      ...toRefs(state),
      handleButtonClick
    }
  }
})
</script>

<template>
  <div class="component-info-button-container" :style="{ width: `${width}px` }" :class="disabled ? 'disabled' : ''"
    @click="handleButtonClick">
    {{ title }}
  </div>
</template>

<style lang="scss">
.component-info-button-container {
  height: 26px;
  border: 1px solid #A3A3A3;
  display: flex;
  align-items: center;
  justify-content: center;
  user-select: none;
  cursor: pointer;
  font-size: 14px;
  background-color: #F2F2F2;

  &.disabled {
    color: #CEC9D7;
  }
}
</style>
